home *** CD-ROM | disk | FTP | other *** search
/ 5 Star Games: DOS Edition 2 / 5 Star Games - DOS Edition (1995)(Ready to Run).iso / dbc / mb.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-03  |  1.9 KB  |  84 lines

  1. #ifdef __TURBOC__
  2.     #include <conio.h>
  3. #else
  4.     #include <conio.h>
  5.     #include <graph.h>
  6.     #include <dos.h>
  7. #endif
  8. #include <io.h>
  9. #include <process.h>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <dos.h>
  14. #include "db_types.h"
  15. #include "db_conio.h"
  16. #include "db_dos.h"
  17. #include "db_file.h"
  18. #include "db_gvar.h"
  19. #include "db_lsc.h"
  20. #include "db_str.h"
  21.  
  22. bool batch, delchain;
  23. byte col,row,attr,savmode,newmode;
  24. int i, execstat;
  25. pathstr mbprog;
  26. uchar glostr[129], mbcmd[129];
  27. string tts;
  28.  
  29. word getvmode(void)
  30. {
  31.     union REGS reg;
  32.  
  33.     reg.h.ah = 15;
  34.  
  35. /*    swinterrupt(0x10,®,®); */
  36.  
  37.     int86(0x10, ®, ®);
  38.     return (reg.h.al);
  39. }
  40.  
  41. void main(void)
  42. {
  43.     getscreeninfo(&savmode,&col,&row,&attr);
  44.     db_gvar_init();
  45.     mbcmd[0] = 0; batch = False; delchain = False;
  46.     pointer2string(tts,dgvar);
  47.     strconcat(glostr," ",recog,tts,NULL);
  48.     for (i = 1; i < paramcount(); i++) {
  49.         strcpy(tts,paramstr(i));
  50.         if (strncmp("-AE",tts,3) == 0) delchain = False;
  51.         if (strcmp(tts,"-BL") == 0) batch = True;
  52.         else if ((tts[0] == '-') && (strncmp("-AE",tts,3) != 0)) strconcat(glostr,glostr," ",tts,NULL);
  53.         else strconcat(mbcmd,mbcmd," ",tts,NULL);
  54.     }
  55.     if (delchain) {
  56.         tts[0] = '_'; getenvstr(&tts[1],"MBSTN");
  57.         unlink(strcat(tts,"LOOP.BAT"));
  58.     }
  59.     if (batch) {
  60.         strcat(mbcmd,glostr);
  61.         getenvstr(tts,"PATH");
  62.         strconcat(tts,tts,";",thisprog.fdir,NULL);
  63.         fsearch(mbprog,"MBRUN.EXE",tts);
  64.         do {
  65.             execstat = spawnlp(P_WAIT,mbprog,mbprog,mbcmd,NULL);
  66.             if ((execstat==98) || (execstat==99)) {
  67.                 i = spawnlp(P_WAIT,gvar->prog,gvar->prog,gvar->cmd,NULL);
  68.                 strconcat(mbcmd,gvar->reentry,glostr,NULL);
  69.                 newmode = (byte)getvmode();
  70.                 if (execstat==98) {
  71.                     cwrite("\n\r");
  72.                cwrite(LSC_PressAnyKey);
  73.                     getch();
  74.                 }
  75.                 if (savmode != newmode) textmode(savmode);
  76.             }
  77.         } while ((execstat == 98) || (execstat == 99));
  78.     }
  79.     else {
  80.       cwrite(LSC_StartVia);
  81.         cwrite(" STARTMB.BAT");
  82.    }
  83. }
  84.